package controllers;

import models.*;
import java.util.*;
import play.db.jpa.*;
import play.classloading.enhancers.ControllersEnhancer.ControllerInstrumentation;

/**
 *
 * @author Ivan
 */
public class TimeOut extends TimerTask {

        Long provId;
        Long userId;
        Status status;

        public TimeOut(Long provId, Long userId, Status status) {
                this.provId = provId;
                this.userId = userId;
                this.status = status;
        }

        public void run() {
                ControllerInstrumentation.initActionCall();
                JPAPlugin.startTx(false);
                if (((Trips.getStatus(provId,userId) == status) || (Trips.getStatus(provId,userId) == Status.p_accepted)) && (status == Status.u_requested)) {
                        StatusController.provAcceptCanceled(userId, provId);
                } else if ((Trips.getStatus(provId,userId) == status) && (status == Status.p_accepted)) {
                        StatusController.userCanceled(provId, userId);
                } else {
                        System.out.println("Invalid param status");
                }
        }
}
